package com.chinda.modules.job.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.chinda.common.enums.ScheduleStatusEnum;
import com.chinda.common.page.RPage;
import com.chinda.modules.job.entity.ScheduleJobEntity;
import com.chinda.modules.job.qo.ScheduleJobQO;

import java.util.List;


/**
 * 定时任务
 *
 * @author chinda
 * @date 2021-07-09 19:09:10
 */
public interface ScheduleJobService extends IService<ScheduleJobEntity> {

    /**
     * 获取分页信息
     * @param qo
     * @return
     */
    RPage page(ScheduleJobQO qo);

    /**
     * 立即执行
     * @param jobIds
     */
    void run(Long[] jobIds);

    /**
     * 暂停运行
     * @param jobIds
     */
    void pause(Long[] jobIds);

    /**
     * 恢复运行
     * @param jobIds
     */
    void resume(Long[] jobIds);

    /**
     * 批量更新任务状态
     *
     * @param jobIds
     * @param status
     * @return
     */
    boolean updateBatch(Long[] jobIds, ScheduleStatusEnum status);

    /**
     * 批量删除定时任务
     * @param asList
     */
    void deleteBatch(List<Long> asList);

    /**
     * 删除定时任务
     * @param jobId
     */
    void deleteById(Long jobId);

    /**
     * 更新定时任务
     * @param dbScheduleJob
     * @return
     */
    boolean updateJob(ScheduleJobEntity dbScheduleJob);

    /**
     * 保存定时任务
     * @param scheduleJob
     */
    void saveJob(ScheduleJobEntity scheduleJob);
}

